package com.test.controller;

import com.test.common.BaseResponse;
import com.test.common.ResultUtils;
import com.test.model.pojo.TrueFalseQuestion;
import com.test.service.TrueFalseQuestionService;
import com.test.service.WordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/tf")
public class TrueFalseQuestionsController {

    @Autowired
    TrueFalseQuestionService TFService;

    @GetMapping("/test")
    public BaseResponse<List<TrueFalseQuestion>> getAllTFQuestions(){
        List<TrueFalseQuestion> questions = TFService.getAllTFQuestions();
        return ResultUtils.success(questions);
    }

    @GetMapping("/getCount")
    public BaseResponse<Integer> getQuestionCounts(){
        Integer counts = TFService.getCounts();
        return ResultUtils.success(counts);
    }

    @GetMapping("/getQuestionById/{id}")
    public BaseResponse<TrueFalseQuestion> getTFQById(@PathVariable Integer id){
        TrueFalseQuestion question = TFService.getQuestionById(id);
        return ResultUtils.success(question);
    }
}